Dynomotion

Group: DynoMotion Message: 4284 From: bob_burig Date: 3/21/2012
Subject: Wrong values from Persist.UserData[198]
I have loaded a table of values. 21 rows of 3 columns. I can print the table to the console.
I want to execute each row sequentially,1-21, where each column is a position command to 3 axis, x,y,z.
The values being sent to the three axis are not the values in the table, in fact all three axis are getting the same wrong value.
I am using MoveXYZABC (x, y, z, 0.0, 0.0, 0.0)
Group: DynoMotion Message: 4285 From: Tom Kerekes Date: 3/21/2012
Subject: Re: Wrong values from Persist.UserData[198]
Hi Bob,
 
You forgot to include your code so we can see what you are doing.
 
Regards
TK

Group: DynoMotion Message: 4286 From: bob_burig Date: 3/21/2012
Subject: Re: Wrong values from Persist.UserData[198]
Hi Tom,

Yes I did, but here it is.

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++

#include "KMotionDef.h"
#include "prolab.h"


/* This program assumes that thread #1 has configured all of the axes
that are to be used */

#define LENS 1
#define ECCENTRIC 4
#define ROTATION 6
#define Enable

void main(void)
{

extern int CS0_axis_x;
extern int CS0_axis_y;
extern int CS0_axis_z;
extern int CS0_axis_a;
extern int CS0_axis_b;
extern int CS0_axis_c;
extern int *theta, *offset, *surface_angle;
extern double scale_theta, scale_offset, scale_surface_angle;

int i, nrows;
double x, y, z;

nrows = 21;

persist.UserData[198] = 0; /* clear coordinated motion flag */

ch1->Vel = 500;
ch1->Accel= 20000;
ch4->Vel = 30000;
ch4->Accel= 50000;
ch6->Vel = 30000;
ch6->Accel= 50000;
/* Below are external variables CS0_axis_$ that are used by
DefineCoordSystem6() */
CS0_axis_x = LENS;

CS0_axis_y = ECCENTRIC;
CS0_axis_z = ROTATION;
CS0_axis_a = -1;
CS0_axis_b = -1;
CS0_axis_c = -1;

DefineCoordSystem6(CS0_axis_x, CS0_axis_y, CS0_axis_z, CS0_axis_a,
CS0_axis_b, CS0_axis_c);
Enable 1;
Enable 4;
Enable 6;
while (TRUE) {
if (persist.UserData[198] == 1) {
/* Now execute code for movement */

Zero(LENS);
Zero(ECCENTRIC);
Zero(ROTATION);
for (i = 0; i < nrows; ++i) {
/* MoveXYZABC(double x, double y, double z, double a, double b, double
c) Input
- double x is the distance to move the x-axis in the coordinate system
- double y is the distance to move the y-axis in the
coordinate system
- double z is the distance to move the z-axis in the coordinate system
- double a is the distance to move the a-axis in the
coordinate system
- double b is the distance to move the b-axis in the
coordinate system
- double c is the distance to move the c-axis in the
coordinate system

NOTE: Since we would like to execute the next coordinated movement once
the current
coordinated movement is finished, individually check to see that all
three axes
movements are done before continuing to the next coordinated movement.
We would not
have to individually check to see if the motion was done if we had set
up a specific
trajectory for the axes to follow, but that may not be appropriate for
our needs.
Also, since theta, offset, and surface_angle are integer pointers, we
have to cast
the scaled values to double before input.
*/
x = (double) theta[i];
y = (double) offset[i];
z = (double) surface_angle[i];

/* Now execute the simultaneous motion of the three axes for each
specified distance listed in the CAM table.*/

MoveXYZABC(x, y, z, 0.0, 0.0, 0.0);
printf("moving to\n\n");
printf("%27.4f", x );
printf("%27.4f", y );
printf("%27.4f\n",
z);
/* wait until all axes have completed motion */
while (!CheckDone(LENS) || !CheckDone(ECCENTRIC) ||
!CheckDone(ROTATION));
/* clear coordinated motion flag */

persist.UserData[198] = 0;
}
}
}


--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> Hi Bob,
> Â
> You forgot to include your code so we can see what you are doing.
> Â
> Regards
> TK
>
>
> ________________________________
> From: bob_burig bob_burig@...
> To: DynoMotion@yahoogroups.com
> Sent: Wednesday, March 21, 2012 1:45 PM
> Subject: [DynoMotion] Wrong values from Persist.UserData[198]
>
>
> Â
> I have loaded a table of values. 21 rows of 3 columns. I can print the
table to the console.
> I want to execute each row sequentially,1-21, where each column is a
position command to 3 axis, x,y,z.
> The values being sent to the three axis are not the values in the
table, in fact all three axis are getting the same wrong value.
> I am using MoveXYZABC (x, y, z, 0.0, 0.0, 0.0)
>
Group: DynoMotion Message: 4287 From: Tom Kerekes Date: 3/21/2012
Subject: Re: Wrong values from Persist.UserData[198]
Hi Bob,
 
I don't see where you had included it.
 
Now I can't find prolab.h
 
Otherwise I don't see anything unusual except:
 
#define
Enable
Enable 1;
Enable 4;
Enable 6;
 
because the macro defines Enable to be nothing this results in the do-nothing but legal code of:
 
1;
4;
6;
 
probably should be:
 
Enable(1);
Enable(4);
Enable(6);
 
Are the axes actually enabled when it runs?
 
What happens?  What is printed on the console?
 
Regards
TK
 

Group: DynoMotion Message: 4288 From: bob_burig Date: 3/21/2012
Subject: Re: Wrong values from Persist.UserData[198]
Hi Tom,
In editing the program, I made some errors. I should have read:

#define Enable;
Enable 1;
Enable 2;
Enable 3;

The three axis are enabled and do move, but to wrong positions

My first 3 table values are:
x, 100 y, 100 z, 3850
x, 200 y, 200 z, 7700
x, 300 y, 300 z, 11550

Console printed values are:
x, 3090 y, 3090 z, 3090
x, 32586 y, 32586 z, 32586
z, 985654253 y, 985654253 z, 985654253

The axis are enabled and do move to these positions (3rd values cause axis faults)


--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> Hi Bob,
>  
> I don't see where you had included it.
>  
> Now I can't find prolab.h
>  
> Otherwise I don't see anything unusual except:
>  #defineEnableEnable 1;
> Enable 4;
> Enable 6;
>  
> because the macro defines Enable to be nothing this results in the do-nothing but legal code of:
>  
> 1;
> 4;
> 6;
>  
> probably should be:
>  Enable(1);
> Enable(4);
> Enable(6);
>  
> Are the axes actually enabled when it runs?
>  
> What happens?  What is printed on the console?
>  
> Regards
> TK
>  
>
>
> ________________________________
> From: bob_burig <bob_burig@...>
> To: DynoMotion@yahoogroups.com
> Sent: Wednesday, March 21, 2012 3:25 PM
> Subject: [DynoMotion] Re: Wrong values from Persist.UserData[198]
>
>
>  
>
> Hi Tom,
>
> Yes I did, but here it is.
>
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> #include "KMotionDef.h"
> #include "prolab.h"
>
> /* This program assumes that thread #1 has configured all of the axes
> that are to be used */
>
> #define LENS 1
> #define ECCENTRIC 4
> #define ROTATION 6
> #define Enable
>
> void main(void)
> {
>
> extern int CS0_axis_x;
> extern int CS0_axis_y;
> extern int CS0_axis_z;
> extern int CS0_axis_a;
> extern int CS0_axis_b;
> extern int CS0_axis_c;
> extern int *theta, *offset, *surface_angle;
> extern double scale_theta, scale_offset, scale_surface_angle;
>
> int i, nrows;
> double x, y, z;
>
> nrows = 21;
>
> persist.UserData[198] = 0; /* clear coordinated motion flag */
>
> ch1->Vel = 500;
> ch1->Accel= 20000;
> ch4->Vel = 30000;
> ch4->Accel= 50000;
> ch6->Vel = 30000;
> ch6->Accel= 50000;
> /* Below are external variables CS0_axis_$ that are used by
> DefineCoordSystem6() */
> CS0_axis_x = LENS;
>
> CS0_axis_y = ECCENTRIC;
> CS0_axis_z = ROTATION;
> CS0_axis_a = -1;
> CS0_axis_b = -1;
> CS0_axis_c = -1;
>
> DefineCoordSystem6(CS0_axis_x, CS0_axis_y, CS0_axis_z, CS0_axis_a,
> CS0_axis_b, CS0_axis_c);
> Enable 1;
> Enable 4;
> Enable 6;
> while (TRUE) {
> if (persist.UserData[198] == 1) {
> /* Now execute code for movement */
>
> Zero(LENS);
> Zero(ECCENTRIC);
> Zero(ROTATION);
> for (i = 0; i < nrows; ++i) {
> /* MoveXYZABC(double x, double y, double z, double a, double b, double
> c) Input
> - double x is the distance to move the x-axis in the coordinate system
> - double y is the distance to move the y-axis in the
> coordinate system
> - double z is the distance to move the z-axis in the coordinate system
> - double a is the distance to move the a-axis in the
> coordinate system
> - double b is the distance to move the b-axis in the
> coordinate system
> - double c is the distance to move the c-axis in the
> coordinate system
>
> NOTE: Since we would like to execute the next coordinated movement once
> the current
> coordinated movement is finished, individually check to see that all
> three axes
> movements are done before continuing to the next coordinated movement.
> We would not
> have to individually check to see if the motion was done if we had set
> up a specific
> trajectory for the axes to follow, but that may not be appropriate for
> our needs.
> Also, since theta, offset, and surface_angle are integer pointers, we
> have to cast
> the scaled values to double before input.
> */
> x = (double) theta[i];
> y = (double) offset[i];
> z = (double) surface_angle[i];
>
> /* Now execute the simultaneous motion of the three axes for each
> specified distance listed in the CAM table.*/
>
> MoveXYZABC(x, y, z, 0.0, 0.0, 0.0);
> printf("moving to\n\n");
> printf("%27.4f", x );
> printf("%27.4f", y );
> printf("%27.4f\n",
> z);
> /* wait until all axes have completed motion */
> while (!CheckDone(LENS) || !CheckDone(ECCENTRIC) ||
> !CheckDone(ROTATION));
> /* clear coordinated motion flag */
>
> persist.UserData[198] = 0;
> }
> }
> }
>
> --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> >
> > Hi Bob,
> > Â
> > You forgot to include your code so we can see what you are doing.
> > Â
> > Regards
> > TK
> >
> >
> > ________________________________
> > From: bob_burig bob_burig@
> > To: DynoMotion@yahoogroups.com
> > Sent: Wednesday, March 21, 2012 1:45 PM
> > Subject: [DynoMotion] Wrong values from Persist.UserData[198]
> >
> >
> > Â
> > I have loaded a table of values. 21 rows of 3 columns. I can print the
> table to the console.
> > I want to execute each row sequentially,1-21, where each column is a
> position command to 3 axis, x,y,z.
> > The values being sent to the three axis are not the values in the
> table, in fact all three axis are getting the same wrong value.
> > I am using MoveXYZABC (x, y, z, 0.0, 0.0, 0.0)
> >
>
Group: DynoMotion Message: 4289 From: Tom Kerekes Date: 3/21/2012
Subject: Re: Wrong values from Persist.UserData[198]
Hi Bob,
 
Since the console printed positions are wrong that would indicate that either putting in the values into the table or getting them out is wrong.  But you aren't showing us how you are doing that.
 
The #define Enable; would still do nothing.  What are you trying to do there?
 
Regards
TK

Group: DynoMotion Message: 4290 From: bob_burig Date: 3/21/2012
Subject: Re: Wrong values from Persist.UserData[198]
Hi Tom,

I added #define Enable when the compiler complained about Enable.

I'll send along the program for entering the data when I get back to my lab tomorrow.

Bob

--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> Hi Bob,
>  
> Since the console printed positions are wrong that would indicate that either putting in the values into the table or getting them out is wrong.  But you aren't showing us how you are doing that.
>  
> The #define Enable; would still do nothing.  What are you trying to do there?
>  
> Regards
> TK
>
>
> ________________________________
> From: bob_burig <bob_burig@...>
> To: DynoMotion@yahoogroups.com
> Sent: Wednesday, March 21, 2012 6:59 PM
> Subject: [DynoMotion] Re: Wrong values from Persist.UserData[198]
>
>
>  
> Hi Tom,
> In editing the program, I made some errors. I should have read:
>
> #define Enable;
> Enable 1;
> Enable 2;
> Enable 3;
>
> The three axis are enabled and do move, but to wrong positions
>
> My first 3 table values are:
> x, 100 y, 100 z, 3850
> x, 200 y, 200 z, 7700
> x, 300 y, 300 z, 11550
>
> Console printed values are:
> x, 3090 y, 3090 z, 3090
> x, 32586 y, 32586 z, 32586
> z, 985654253 y, 985654253 z, 985654253
>
> The axis are enabled and do move to these positions (3rd values cause axis faults)
>
> --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> >
> > Hi Bob,
> >  
> > I don't see where you had included it.
> >  
> > Now I can't find prolab.h
> >  
> > Otherwise I don't see anything unusual except:
> >  #defineEnableEnable 1;
> > Enable 4;
> > Enable 6;
> >  
> > because the macro defines Enable to be nothing this results in the do-nothing but legal code of:
> >  
> > 1;
> > 4;
> > 6;
> >  
> > probably should be:
> >  Enable(1);
> > Enable(4);
> > Enable(6);
> >  
> > Are the axes actually enabled when it runs?
> >  
> > What happens?  What is printed on the console?
> >  
> > Regards
> > TK
> >  
> >
> >
> > ________________________________
> > From: bob_burig <bob_burig@>
> > To: DynoMotion@yahoogroups.com
> > Sent: Wednesday, March 21, 2012 3:25 PM
> > Subject: [DynoMotion] Re: Wrong values from Persist.UserData[198]
> >
> >
> >  
> >
> > Hi Tom,
> >
> > Yes I did, but here it is.
> >
> > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >
> > #include "KMotionDef.h"
> > #include "prolab.h"
> >
> > /* This program assumes that thread #1 has configured all of the axes
> > that are to be used */
> >
> > #define LENS 1
> > #define ECCENTRIC 4
> > #define ROTATION 6
> > #define Enable
> >
> > void main(void)
> > {
> >
> > extern int CS0_axis_x;
> > extern int CS0_axis_y;
> > extern int CS0_axis_z;
> > extern int CS0_axis_a;
> > extern int CS0_axis_b;
> > extern int CS0_axis_c;
> > extern int *theta, *offset, *surface_angle;
> > extern double scale_theta, scale_offset, scale_surface_angle;
> >
> > int i, nrows;
> > double x, y, z;
> >
> > nrows = 21;
> >
> > persist.UserData[198] = 0; /* clear coordinated motion flag */
> >
> > ch1->Vel = 500;
> > ch1->Accel= 20000;
> > ch4->Vel = 30000;
> > ch4->Accel= 50000;
> > ch6->Vel = 30000;
> > ch6->Accel= 50000;
> > /* Below are external variables CS0_axis_$ that are used by
> > DefineCoordSystem6() */
> > CS0_axis_x = LENS;
> >
> > CS0_axis_y = ECCENTRIC;
> > CS0_axis_z = ROTATION;
> > CS0_axis_a = -1;
> > CS0_axis_b = -1;
> > CS0_axis_c = -1;
> >
> > DefineCoordSystem6(CS0_axis_x, CS0_axis_y, CS0_axis_z, CS0_axis_a,
> > CS0_axis_b, CS0_axis_c);
> > Enable 1;
> > Enable 4;
> > Enable 6;
> > while (TRUE) {
> > if (persist.UserData[198] == 1) {
> > /* Now execute code for movement */
> >
> > Zero(LENS);
> > Zero(ECCENTRIC);
> > Zero(ROTATION);
> > for (i = 0; i < nrows; ++i) {
> > /* MoveXYZABC(double x, double y, double z, double a, double b, double
> > c) Input
> > - double x is the distance to move the x-axis in the coordinate system
> > - double y is the distance to move the y-axis in the
> > coordinate system
> > - double z is the distance to move the z-axis in the coordinate system
> > - double a is the distance to move the a-axis in the
> > coordinate system
> > - double b is the distance to move the b-axis in the
> > coordinate system
> > - double c is the distance to move the c-axis in the
> > coordinate system
> >
> > NOTE: Since we would like to execute the next coordinated movement once
> > the current
> > coordinated movement is finished, individually check to see that all
> > three axes
> > movements are done before continuing to the next coordinated movement.
> > We would not
> > have to individually check to see if the motion was done if we had set
> > up a specific
> > trajectory for the axes to follow, but that may not be appropriate for
> > our needs.
> > Also, since theta, offset, and surface_angle are integer pointers, we
> > have to cast
> > the scaled values to double before input.
> > */
> > x = (double) theta[i];
> > y = (double) offset[i];
> > z = (double) surface_angle[i];
> >
> > /* Now execute the simultaneous motion of the three axes for each
> > specified distance listed in the CAM table.*/
> >
> > MoveXYZABC(x, y, z, 0.0, 0.0, 0.0);
> > printf("moving to\n\n");
> > printf("%27.4f", x );
> > printf("%27.4f", y );
> > printf("%27.4f\n",
> > z);
> > /* wait until all axes have completed motion */
> > while (!CheckDone(LENS) || !CheckDone(ECCENTRIC) ||
> > !CheckDone(ROTATION));
> > /* clear coordinated motion flag */
> >
> > persist.UserData[198] = 0;
> > }
> > }
> > }
> >
> > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > >
> > > Hi Bob,
> > > Â
> > > You forgot to include your code so we can see what you are doing.
> > > Â
> > > Regards
> > > TK
> > >
> > >
> > > ________________________________
> > > From: bob_burig bob_burig@
> > > To: DynoMotion@yahoogroups.com
> > > Sent: Wednesday, March 21, 2012 1:45 PM
> > > Subject: [DynoMotion] Wrong values from Persist.UserData[198]
> > >
> > >
> > > Â
> > > I have loaded a table of values. 21 rows of 3 columns. I can print the
> > table to the console.
> > > I want to execute each row sequentially,1-21, where each column is a
> > position command to 3 axis, x,y,z.
> > > The values being sent to the three axis are not the values in the
> > table, in fact all three axis are getting the same wrong value.
> > > I am using MoveXYZABC (x, y, z, 0.0, 0.0, 0.0)
> > >
> >
>
Group: DynoMotion Message: 4291 From: i2trsteele Date: 3/22/2012
Subject: Re: Wrong values from Persist.UserData[198]
Tom,

/* I'll send you all of the necessary files I've created so far. The comments below will them make sense */

(Bob, thanks for getting the conversation started, as I had to take care of my 5 1/2 mo. old son. Bob is a fantastic engineer and he's been picking up my slack because of paperwork issues between companies slowing the project down.)

What Bob is trying to accomplish is this:

Tom, when I spoke to you last I was trying to pass in data from a text file to the double gather_buffer and then from there cast that pointer as an integer to read the integer values I read in from the text file. I know that this was successful because I was able to print out those values to the console screen. That table is meant to be a CAM table. I'll explain below:

There are three columns for three axes. This is the modified "Download Waveform.exe" we had talked about before. I used fscanf to read the lines of (signed) integers and writes those values to the gather_buffer using the console command "SetPersistDec# integer". This sets the UserData[199] = 1 when it is completed loading data to the controller.

I have a separate thread "prolab.c" that has a while(TRUE) {...} loop looks for a persist.UserData[199] == 1. When this flag is set by "Download Waveform.exe" The values from the gather_buffer are saved to (3) external integer pointers that defined in "prolab.h" (placed in the DSP_KFLOP folder for compilation). Their memory is allocated using (int *) calloc() in "prolab.c". Their pointers are not freed since I would like to point to that memory for the entire execution time. When I am done reading all the rows of (3) integers, I then print those values to ensure that they are being read correctly. (and this has been verified) Those externally defined integer pointers are

Now this is where the questions come out:

I have another thread that is called camtest.c that looks for the UserData[198] flag to be set in the same fashion as "prolab.c", except Bob's main thread is the program that sets this flag. His main thread sets all of the axes channels that are to be used and enables those axes. These axes are NOT to be placed on a trajectory because the CAM table should take care of telling each of the axes where to move next.

In camtest.c, I am defining the coordinate system to be used. I am using DefineCoordsystem6() where the a,,b, and c axes are disabled.

extern int *theta, *offset, *surface_angle /* CAM table */
double x, y, z;
.
.
.
CS0_axis_x = LENS; /* #define LENS 1 */
CS0_axis_y = ECCENTRIC; /* #define ECCENTRIC 5 */
CS0_axis_z = ROTATION; /* #define ROTATION 6 */
CS0_axis_a = -1;
CS0_axis_b = -1;
CS0_axis_c = -1;

DefineCoordSystem6(CS0_axis_x, CS0_axis_y, CS0_axis_z, CS0_axis_a, CS0_axis_b, CS0_axis_c);

Now I enter the for-loop where for each row of integer positions I would like to move each axis to the integer positions. When all of the motions have been completed, loop through again to the next row of positions in the CAM table.

x = (double) theta[i];
y = (double) offset[i];
z = (double) surface_angle;

MoveXYZABC(x, y, z, 0.0, 0.0, 0.0);

while (!CheckDone(LENS) || !CheckDone(ECCENTRIC) || !CheckDone(ROTATION));

Once all of the rows of data have been read, and the for-loop has been exited, the UserData[198] flag is then cleared.


QUESTIONS:
==========

---> Is there a problem with the (double) cast for the x, y, z values since they were read from the double gather_buffer? (I think this is where the positions are off, but I could be wrong.)

---> Is MoveXYZABC() an incremental move or an absolute move?

---> Do I have to set/initialize the CS0_axis_$ values in camtest.c?

Thanks for your help TK.
Group: DynoMotion Message: 4292 From: i2trsteele Date: 3/22/2012
Subject: Re: Wrong values from Persist.UserData[198]
TK,

Turns out the (double) cast is the problem. Since I am originally pointing to on half of the double gather_buffer pointer position (via the integer pointer cast), i am grabbing the entire position in the gather_buffer position in memory, which is incorrect.

I'll work on it a little form here.
Group: DynoMotion Message: 4295 From: bob_burig Date: 3/22/2012
Subject: Re: Wrong values from Persist.UserData[198]
HiTom,

We solved the problem with reading the values.

Now, how large can an integer array be on a single thread?

Bob

--- In DynoMotion@yahoogroups.com, "i2trsteele" <i2trsteele@...> wrote:
>
> TK,
>
> Turns out the (double) cast is the problem. Since I am originally pointing to on half of the double gather_buffer pointer position (via the integer pointer cast), i am grabbing the entire position in the gather_buffer position in memory, which is incorrect.
>
> I'll work on it a little form here.
>
Group: DynoMotion Message: 4299 From: Tom Kerekes Date: 3/22/2012
Subject: Re: Wrong values from Persist.UserData[198]
Hi Bib,
 
Global Thread memory for threads 1-6 is 64KBytes.  Thread #7 is 5x64KBytes.  Thread memory can be combined where one thread can overflow into the next as long as the next thread is not used.
 
Otherwise there is 8MBytes of gather buffer that you might use.
 
Regards
TK